home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / postogrf.zip / POSTOGRF.PAS < prev    next >
Pascal/Delphi Source File  |  1990-08-10  |  63KB  |  1,625 lines

  1. {$A+,B-,D+,E-,F-,I+,L+,N-,O-,R-,S-,V-}
  2. {$M 32000,0,655360}
  3. Program POSTogrf;
  4. { (O] SCRC Z; EXIT; }
  5. {    Written by T. B. Passin in Turbo Pascal 5.0.
  6.      Writes labels onto graphs using Postscript laser printer.  The labels
  7.      can be moved, sized, edited, and the font can be chosen.  This
  8.      program takes as input the graph file from J. R. VanZandt's
  9.      graph program GRAPHLI, which is a version of GRAPH that puts
  10.      out a command file that drives the C. Itoh LIPS laser printer.
  11.      POSTOGRF also can read its own output file, the output from LIPSOGRF,
  12.      and the output from VanZandt's GRAPHPS.
  13.  
  14.      POSTOGRF interactively adds labels to the file and outputs
  15.      a merged file containing both the graph and the labels ready to print
  16.      on a Postscript printer.
  17.  
  18.     10 Aug 90 v6.14. Changes default font style when you change font.
  19.     4 June 90 v6.14x5.
  20.     31 May 90 v6.14x3 Now can also size CopyBlock automatically, or with
  21.        mover keys.  Changed CopyBLock menu item function keys.
  22.     25 May 90 v6.14x2.  Now has new mode: F8, moves Copyblock around
  23.        on page. Adjusted Copyblock defaults and positions of the VG
  24.        bar & MITRE Logo.  Most changes are to Copybloc.inc.  CopyBlock
  25.        now described in Postscript coords relative to origin.  Added
  26.        types Rect, ScreenRect.  Added var CopyBlock.
  27.     21 May 90 v6.14x1.  Now rotates labels 90 deg.  2 new Postscript
  28.        words for this: 'rs' rotates and does 's', 'rsho' rotates and does
  29.         'show'.
  30.      2 May 90 v6.13e.  'X' option now autosaves without requesting
  31.         confirmation for output filename (omit save if unchanged).
  32.      25 Apr 90 v6.13d. Now defaults to 'y' for save when quitting.  Added
  33.         'X' exit option: automatically saves file before quitting.
  34.      18 Apr 90 v6.13c. Minor fix for read-file message.
  35.      17 Apr90 v6.13b. Bug fix in init:split into init + init1, init1 comes
  36.          before ReadGRAPHLI. Initscrn now before ReadGRAPHLI;  Now new labels
  37.          are spaced right in expanded viewing (fix AddLabel);
  38.      28 Mar 90 v6.13.  Slightly increased default vertical spacing between
  39.          labels.  Bug fix: after exiting a file without changing it,
  40.          a new file (no filename) no longer incorporates the previous one
  41.          (fixed Init, WritePrt);  New file: label background now transparent.
  42.          Label background now defaults to most recent setting. ^-home, ^-end
  43.          now select head, tail of linked list, Home = PF6, End = PF8.
  44.          Now F10 to save/quit, new main menu.
  45.      18 Jan 90. v6.12. No confirmation needed to write to LPT3, COM3.
  46.      5 Jan 90. v 6.11.  Now uses VGA mode: changes to init, initscreen.
  47. }
  48.  
  49. Uses Graph, CRT, DOS,
  50.      Lipsfont,   { BGI sansserif font }
  51.      lipsdrvr; { all the BGI drivers (except 3270) }
  52. {$DEFINE POSTOGRF}
  53. {$I pstrings.i}
  54. {$I beboop.src}
  55. {type db = array[1..100] of char;
  56.      dbPtr = ^db;}
  57.  
  58. Type Fontlist = (Times, TimesBold, Helv, HelvBold, Symbol,
  59.                  MitreLogo);
  60.      paintType = (trans, opaque);
  61.      FontRec = record
  62.                   {POSTabrv   : string[6];}
  63.                   FontNum  : integer;
  64.                   LipsStyle: Fontlist;
  65.                   FontStr  : string[80];      (* font descriptor *)
  66.                end;                      (* for reference only: *)
  67.      TextPtr = ^TextRec;                 (* TextSettingsType - record *)
  68.      {String80 = string[80];}            (*   Font          : word; *)
  69.      TextRec = Record                    (*   Direction     : word; *)
  70.         Link:  TextPtr;                  (*   CharSize      : word; *)
  71.         Tstr:  string[80] ;              (*   Horiz         : word; *)
  72.         CurrText: TextSettingsType ;     (*   Vert          : word; end; *)
  73.         PrtSize: integer; (* in points *)
  74.         LipsFont: FontRec;
  75.         LabelBkGround: paintType;
  76.      end ;
  77.      String6 = string[6];
  78.  
  79.      StyleNames = array [Times..MitreLogo] of string[20];
  80.      StyleAbrv = array [Times..MitreLogo] of string6 ;
  81.  
  82.      Filearray = array[1..65000] of char;
  83.      Fileptr = ^Filearray;
  84.  
  85.      ConfigRec = record
  86.                    WriteMitreLogo: boolean;
  87.                    DoBar: boolean;
  88.                  end;
  89.  
  90.      ExpandoRec = record
  91.                     SF,              {scale factor for expansion}
  92.                     Xcent,           {new screen center in original}
  93.                     Ycent,           {unscaled screen coordinates}
  94.                     ScrnW,           {1/2 new screen width}
  95.                     ScrnH: integer;  {1/2 new screen height}
  96.                    end;
  97.  
  98.      Rect       = record
  99.                    LLx, LLy, URx, URy, w, h: integer; end;
  100.      ScreenRect = record
  101.                    ULx, ULy, LRx, LRy, sw, sh: integer; end;
  102.  
  103.      PointRec = record x,y: integer; end;
  104.      LayoutRec  = record
  105.                   BoundingBox            : Rect;     {in points}
  106.                   Origin                 : PointRec; {in 1/1000's}
  107.                   Landscape, ChangeLayout: boolean;
  108.                 end;
  109.  
  110.      VideoColors = (mono,color);
  111.  
  112.      GraphFileType = (GRAPHL, LIPSGRF, POSTSCRIPT, none);
  113.  
  114.      OnOffType = (on, off);
  115.  
  116.      type CBmodeType = (move, size);
  117.  
  118. const {Yes: set of char = ['Y','y'];}
  119.       UserDiv: byte = 100;
  120.  
  121.       POSTStyleStr : StyleNames = ('Times-Roman', 'Times-Bold', 'Helvetica',
  122.                    'Helvetica-Bold',  'Symbol', 'MitreLogo'{'Courier-Bold'});
  123.  
  124.       UserStyleNames: StyleNames = ('Times', 'TimesBold',
  125.                     'Helv', 'HelvBold', 'Symbol', 'MitreLogo' );
  126.  
  127.       Ver: string80 = 'POSTogrf version 6.14';
  128.       JimDefFontStr = '/font1 /Helvetica-Bold findfont 181 scalefont def';
  129.  
  130.       CharSizeAdjX = 35;  { fudge factor to make screen label the same }
  131.                           { width as printed label }
  132.  
  133.       defaultConfig: ConfigRec = (WriteMitreLogo: false; DoBar: false);
  134.       defaultBarY = 5100;
  135.  
  136.       MitreLogoLabel: TextRec = (
  137.                         Link           : nil;
  138.                         Tstr           : 'MITRE';
  139.                         CurrText: (
  140.                           font         : 100;
  141.                           Direction    : 0;
  142.                           CharSize     : 0;
  143.                           Horiz        : 0;
  144.                           Vert         : 0);
  145.                         PrtSize        : 20;
  146.                         LipsFont: (
  147.                           FontNum      : 100;
  148.                           LIPSStyle    : MitreLogo;
  149.                           FontStr      : '');
  150.                         LabelBkGround  : opaque);
  151.  
  152.       LogoX = 3800; LogoY = -275;   {position of MITRE logo in thousandths}
  153.  
  154.    { ------------------ initial default font params -------------}
  155.       DefaultFsize:integer = 20;
  156.       DefaultLIPSStyle: fontlist = HelvBold;
  157.  
  158.       {ESC = #27;          BS  = #8;            CR = #13;  LF = #10;}
  159.       Uparrow  = #72;     Downarrow  = #80;
  160.       Leftarrow  = #75;   Rightarrow  = #77;
  161.       Del  = #83;         Ins  = #82;
  162.       {Home  = #71;        En  = #79;}  CNTLHome = #119; CNTLEnd = #117;
  163.       PF1 = #59;   PF2 = #60;   PF3 = #61;   PF4 = #62;   PF5 = #63;
  164.       PF6 = #64;   PF7 = #65;   PF8 = #66;   PF9 = #67;   PF10 = #68;
  165.       movers: set of char = [leftarrow, rightarrow, uparrow, downarrow,
  166.                    Home, #115, #116, #73, #81];
  167.  
  168.       { ------------------------------------------------------------- }
  169.       pwhitespace : set of char = [#9, #10, #12, #13, ' ', ',', ';'];
  170.       printables: set of char =
  171.         ['('..'+', '-'..':', '<'..'}', '!', '#'..'&'] ;
  172.       quotes: set of char = [#39,#34];
  173.       numbers: set of char = ['0'..'9','.'];
  174.  
  175.      defaultLayout: LayoutRec = (
  176.                   BoundingBox: (LLx: 0; LLy : 0; URx : 612; URy : 792;
  177.                                  w: 612; h : 792); {points}
  178.                   Origin: (x :7375; y : 1500); {1/1000s in.}
  179.                   Landscape : true;
  180.                   ChangeLayout : false);
  181.  
  182. Var  CurrSettings                              : TextSettingsType ;
  183.      TempText, SaveLastTextRec                 :